Use @ApiProperty() for required fields and @ApiPropertyOptional() for optional fields. Both accept a configuration object for description, example, enum, type, and format. Arrays require explicit type: [ElementType]. Nested DTOs require type: NestedDto. NestJS auto-infers basic types from TypeScript but explicit decorators are required for arrays, enums, and nullable fields.
@ApiProperty() — marks the field as required in the Swagger schema.
@ApiPropertyOptional() — marks the field as optional; equivalent to @ApiProperty({ required: false }).
Arrays require explicit type: [ElementType] — TypeScript metadata does not capture array element types.
Enums require explicit enum: EnumType — TypeScript emits the union type, not the enum object.
Nested DTOs require explicit type: NestedDto — the Swagger plugin can infer this but explicit is safer.